package databaseVersionControl.domain.db;

public class ForeignKey {
	
	private Column column;
//	private String constraintName;
	private String referencedTable;
	private String referencedColumn = "ID";
	
	public ForeignKey(Column column) {
		this.column = column;
	}
	
//	public ForeignKey named(String constraintName) {
//		this.constraintName = constraintName;
//		return this;
//	}
	
	public Column referenceTo(String referencedTable) {
		this.referencedTable = referencedTable;
		return column;
	}
	
	public Column referenceTo(String referencedTable, String referencedColumn) {
		this.referencedTable = referencedTable;
		this.referencedColumn = referencedColumn;
		return column;
	}
	
	@Override
	public String toString() {
		StringBuilder stringBuilder = new StringBuilder();
//      "CONSTRAINT "		
//		stringBuilder.append(constraintName);
//		stringBuilder.append("FOREIGN KEY(");
//		stringBuilder.append(columnName);
		stringBuilder.append(" REFERENCES ");
		stringBuilder.append(referencedTable);
		stringBuilder.append("(");
		stringBuilder.append(referencedColumn);
		stringBuilder.append(")");

		return stringBuilder.toString();
	}

}